﻿using System;
using PsqlDotnet.Enums;

namespace PsqlDotnet.Model.Schema
{
    public class UniqueConstraint : IConstraint
    {
        public UniqueConstraint(string name, string sourceColumn, string sourceTable)
        {
            if (String.IsNullOrWhiteSpace(name) ||
                String.IsNullOrWhiteSpace(sourceColumn) ||
                String.IsNullOrWhiteSpace(sourceTable))
            {
                throw new ArgumentException("Illegal null or empty args");
            }

            Name = name;
            SourceColumn = sourceColumn;
            SourceTable = sourceTable;
        }

        #region IRelation Members

        public ConstraintType RelationType
        {
            get
            {
                return ConstraintType.Unique;
            }
        }

        public string Name { get; private set; }

        public string SourceColumn { get; private set; }

        public string SourceTable { get; private set; }

        #endregion
    }
}
